package com.linkgap.cloud.service;

import com.linkgap.cloud.entity.Department;
import com.linkgap.cloud.repo.DepartmentRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class DepartmentService {
    //2,通过王欢欢id，查询(tb_department)王欢欢id所对应的部门id列表；


    @Autowired
    private DepartmentRepo departmentRepo;
    public List<Long> queryDepartmentListByManagerId(Long managerId) {
        List<Department> departmentList = departmentRepo.findAllByManagerId(managerId);
        //根据王欢欢id查询出部门列表
        List<Long> departmentIdList = new ArrayList<>();
        //定义一个集合接收部门id列表
        for (Department department : departmentList) {
            Long departmentId = department.getId();
            departmentIdList.add(departmentId);
        }
        return departmentIdList;
    }
}
